<?php

namespace Common\Model;

/**
 * VipUserCardRecordModel.class.php实例模型
 *
 * @modify wenhui 2017-12-06    创建
 * @date 2017-12-06
 */
class VipUserCardRecordModel extends BaseModel {

    protected $trueTableName = 'tb_vip_user_card_record';

    /**
     * 返回数据
     * @modify wenhui 2017-12-06    创建
     * @param integer $vipUserId 客栈ID
     * @return array
     */
    public function getVipCardRecord($vipUserId, $startDate = null, $endDate = null, $hotelId = null) {
        if (is_array($vipUserId)) {
            $option['vipuser_id'] = array('in', $vipUserId);
        } else {
            $option['vipuser_id'] = $vipUserId;
        }
        $option['isdelete'] = NOT_DELETE;

        if (!is_null($startDate) && !is_null($endDate)) {
            $option['updatetime'] =  array('between',[$startDate, $endDate]);
        }
        if (!is_null($hotelId)) {
            $option['hotelentity_id'] = $hotelId;
        }

        $field = 'id,vipuser_id,price,change_price,type,pay_type,channel,remark,createtime,operator,updatetime,bk_user_id';

        $data = $this->field($field)->where($option)->order('updatetime desc')->select();
        return empty($data) ? array() : $data;
    }
}
